Schema unification#242
Open
ScriptRaccoon wants to merge 37 commits into
Open
Conversation
5 tasks
9503afb to
2b4e0f8
Compare
69f165a to
1370811
Compare
this change should have been done a while ago actually, namely since the transition from turso to the local sqlite file
this makes the tables source_assumptions and target_assumptions redundant. the structure maps were already implicit in the code at various places. now they are formally implemented. they also allow for extension.
92fbc7c to
dbdafb1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a natural continuation of, and completes, the work started in #193 and #191 on unifying categories and functors across all layers of the application. In particular, it establishes this unification at the database level, which in turn enables the unification of database queries and the associated functions and components.
As a result, a significant amount of code duplication between categories and functors is removed. It also makes it considerably easier to add new categorical structures (#4) without introducing further duplication.
Unified tables
To achieve this, the two largely redundant tables
categoriesandfunctorsare replaced by a singlestructurestable containing all shared data, together with a newtypefield that currently is eithercategoryorfunctor. Similarly, the separate tablescategory_propertiesandfunctor_propertiesare replaced by a singlepropertiestable. Category-specific information is still stored in a dedicatedcategoriestable, which now contains only object and morphism data and uses a reference to thestructurestable as its primary key. Similarly, there is a tablefunctorswhich holds functor-specific data only. For details, see the database diagram below.This change required updates throughout the application, including the SQL schema, seed script, deduction scripts, load functions, and Svelte components.
Database diagram
Before
After
Remark
This is the third attempt at this unification of the schema. The first was never submitted as a PR, and the second was the recent attempt in #224.
Follow Up
Currently, the
idis the primary key for properties. However, this cannot remain as is, since it prevents adding a property such as "cocomplete" for monoidal categories since a corresponding property already exists for categories. (A monoidal category is cocomplete when its underlying category is cocomplete and the tensor product preserves colimits in each variable, which defines a different notion.)One option is to rename properties in a way that avoids collisions, but a more robust solution would be to use the combination of
(id, type)as the primary key. This change can be done in a later PR.